home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Mar 14, 1997
- // Author: laf
- //
- // Description:
- // This script is defines the option box for the rebuild curve menu item.
- //
-
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- rebuildCurveSetOptionVars( $forceFactorySettings );
- }
-
- global proc rebuildCurveSetupLocal( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- rebuildCurveToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- int $useGlobalTol = `optionVar -query rebuildCurveUseGlobalTolerance`;
- radioButtonGrp -e -select (2 - $useGlobalTol) toleranceRadioButtonGrp;
-
- float $localTol = `optionVar -query rebuildCurveLocalTolerance`;
- int $keepOriginal = `optionVar -query rebuildCurveKeepOriginal`;
-
-
- radioButtonGrp -edit -select $useGlobalTol toleranceRadioButtonGrp;
- floatSliderGrp -edit -value $localTol localTolFloatFieldGrp;
-
- if( `checkBoxGrp -q -exists keepOriginalCheckBox` ) {
- checkBoxGrp -edit -value1 $keepOriginal keepOriginalCheckBox;
- }
-
- rebuildCurveSetup( $parent, $forceFactorySettings );
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
- }
-
- //
- // Procedure Name:
- // rebuildCurveOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
- proc rebuildCurveOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "rebuildCurve";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "SetupLocal");
-
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolRebuildCurve";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "rebuildCurveToolScript 3";
-
- // Step 1: Get the option box.
- // ============================
- string $layout = getOptionBox();
- setParent $layout;
-
- // Step 2: Pass the command name to the option box.
- // =================================================
- setOptionBoxCommandName($commandName);
-
- // Step 3: Activate the default UI template.
- // ==========================================
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Step 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- rebuildCurveAddOptions( $parent, 1 );
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Rebuild Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Rebuild"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Rebuild Curve Tool Options");
- }
- else {
- setOptionBoxTitle("Rebuild Curve Options");
- }
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "RebuildCurve" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // rebuildCurveHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
-
- proc string rebuildCurveHelp()
- {
- return
- " Command: Rebuild Curve - perform curve rebuild\n" +
- "Selection: curve, curve on surface";
- }
-
- global proc performRebuildCurvePreset()
- {
- rebuildCurveSetOptionVars( false );
-
- int $doHistory = `constructionHistory -q -tgl`;
- int $replaceOriginal = !`optionVar -q rebuildCurveKeepOriginal`;
- int $rebuildType = `optionVar -q rebuildCurveType`;
- float $globalTol = `optionVar -q positionalTolerance`;
-
- int $crvNumSpans = `optionVar -q rebuildCurveTypeUniformNumSpans`;
- int $crvDegree = `optionVar -q rebuildCurveTypeUniformDegree`;
- int $keepParmRange = `optionVar -q rebuildCurveKeepRange`;
- int $endKnots = `optionVar -q rebuildCurveEndKnots`;
- int $keepControlPoints = `optionVar -q rebuildCurveKeepControlPoints`;
- int $keepEndPts = `optionVar -q rebuildCurveKeepEndPoints`;
- int $keepTan = `optionVar -q rebuildCurveKeepEndTangents`;
- int $keepNumSpans = `optionVar -q rebuildCurveKeepNumSpans`;
- int $crvUseGlobalTol = `optionVar -q rebuildCurveUseGlobalTolerance`;
- float $crvLocalTol = `optionVar -q rebuildCurveLocalTolerance`;
-
- // 0 means keep the existing number of spans
- if( $keepNumSpans ) {
- $crvNumSpans = 0;
- }
-
- performRebuildCurveSet( $doHistory, $replaceOriginal,
- $rebuildType, $globalTol,
- $crvNumSpans, $crvDegree,
- $endKnots,
- $keepParmRange, $keepControlPoints,
- $keepEndPts, $keepTan,
- $crvUseGlobalTol, $crvLocalTol );
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "performRebuildCurveSet";
-
- setOptionVars(false);
-
- int $doHistory = `constructionHistory -q -tgl`;
- int $replaceOriginal = !`optionVar -q rebuildCurveKeepOriginal`;
- int $rebuildType = `optionVar -q rebuildCurveType`;
- float $globalTol = `optionVar -q positionalTolerance`;;
-
- int $crvNumSpans = `optionVar -q rebuildCurveTypeUniformNumSpans`;
- int $crvDegree = `optionVar -q rebuildCurveTypeUniformDegree`;
- int $keepParmRange = `optionVar -q rebuildCurveKeepRange`;
- int $endKnots = `optionVar -q rebuildCurveEndKnots`;
- int $keepControlPoints = `optionVar -q rebuildCurveKeepControlPoints`;
- int $keepEndPts = `optionVar -q rebuildCurveKeepEndPoints`;
- int $keepTan = `optionVar -q rebuildCurveKeepEndTangents`;
- int $keepNumSpans = `optionVar -q rebuildCurveKeepNumSpans`;
- int $crvUseGlobalTol = `optionVar -q rebuildCurveUseGlobalTolerance`;
- float $crvLocalTol = `optionVar -q rebuildCurveLocalTolerance`;
-
- // 0 means keep the existing number of spans
- if( $keepNumSpans ) {
- $crvNumSpans = 0;
- }
-
- $cmd = ( $cmd + " " +
- $doHistory + " " +
- $replaceOriginal + " " +
- $rebuildType + " " +
- $globalTol + " " +
- $crvNumSpans + " " +
- $crvDegree + " " +
- $endKnots + " " +
- $keepParmRange + " " +
- $keepControlPoints + " " +
- $keepEndPts + " " +
- $keepTan + " " +
- $crvUseGlobalTol + " " +
- $crvLocalTol );
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performRebuildCurve
- //
- // Description:
- // Perform the rebuildCurve command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the rebuildCurve command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
-
- global proc string performRebuildCurve(int $action, string $goToTool )
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
-
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
-
- case 1:
- rebuildCurveOptions( $inTheTool, $goToTool );
- break;
-
- case 2:
- default:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-